package com.sad.jetpack.v1.thememanager.api;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;

import androidx.annotation.StyleRes;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

public class BasicThemeDes {
    private int mode=0;
    private String name="默认";
    private int code=0;

    public BasicThemeDes(int mode, String name, int code) {
        this.mode = mode;
        this.name = name;
        this.code = code;
    }

    public BasicThemeDes(){}

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
    public JSONObject toJson(){
        try {
            JSONObject jsonObject=new JSONObject();
            jsonObject.put("name",getName());
            jsonObject.put("code",getCode());
            jsonObject.put("mode",getMode());
            return jsonObject;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public static BasicThemeDes fromJson(JSONObject jsonObject){
        try {
            BasicThemeDes basicThemeDes =new BasicThemeDes();
            basicThemeDes.setCode(jsonObject.optInt("code",0));
            basicThemeDes.setMode(jsonObject.optInt("mode",0));
            basicThemeDes.setName(jsonObject.optString("name","日间"));
            return basicThemeDes;
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }


}
